package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.Account;
import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.CheckingAccount;
import com.acme.bankapp.domain.bank.Client;
import com.acme.bankapp.domain.bank.Gender;
import com.acme.bankapp.domain.bank.SavingAccount;

public class BankService {
	public void addClient(Bank bank, Client client) {
		bank.addClient(client);
	}
	
	public SavingAccount createSavingAccount(double amount) {
		return new SavingAccount(amount);
	}
	
	public Client createClient(String name, Gender gender) {
		return new Client(name, gender);
	}
	
	public CheckingAccount createCheckingAccount(double amount, double overdraft) {
		return new CheckingAccount(amount, overdraft);
	}
	
	public void addAccount(Client client, Account account) {
		client.setAccount(account);
	}
	
	public Bank createBank() {
		return new Bank();
	}
	
	public void printMaximumAmountToWithdraw(Bank bank) {
		for (Client client : bank.getClients()) {
			if (client.getAccount() != null) {
				System.out.println("Maximum amount to withdraw for " + client.getName());
				System.out.println(client.getAccount().maximumAmountToWithdraw());				
			}
		}
	}
}
